<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
    
    </style>
  </head>
  <body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>

    <input type="checkbox" value="" class="checkall" />全选
    <h2 class="box">
      <input type="checkbox" value="" />
      <input type="checkbox" value="" />
      <input type="checkbox" value="" />
    </h2>

    <script>
      console.log(Array.from("foo"));
      // Expected output: Array ["f", "o", "o"]

      const divs = document.querySelectorAll("div");
      console.log(divs); //伪数组
      const arr = Array.from(divs);
      console.log(arr);

      arr.forEach((item) => {
        item.innerHTML = "我是真数组";
      });

      const checkall = document.querySelector(".checkall");
   
      const ipt = document.querySelectorAll(".box input");
      checkall.onchange = function (e) {
        Array.from(ipt).forEach(item=>item.checked=this.checked)
        
    };

   ipt.forEach(function(item){
      item.onchange=function(){
        checkall.checked= Array.from(ipt) .every(item=>item.checked)
      }
    })
    </script>
  </body>
</html>
